package com.wdd.myplatform.service;

import com.alibaba.fastjson2.JSONObject;
import com.wdd.myplatform.common.Result;
import com.wechat.pay.contrib.apache.httpclient.exception.HttpCodeException;
import com.wechat.pay.contrib.apache.httpclient.exception.NotFoundException;
import com.wechat.pay.contrib.apache.httpclient.exception.ParseException;
import com.wechat.pay.contrib.apache.httpclient.exception.ValidationException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URISyntaxException;
import java.security.GeneralSecurityException;
import java.util.Map;

/**
 * @author Administrator
 */
public interface IWeChatService {

    /**
     * 网页授权根据code获取用户信息
     * @param code
     * @return
     */
    Result<?> getWeChatUserInfoByCode(String code);

    /**
     * 根据openId获取用户信息
     * @param openId
     * @return
     */
    Result<?> getWeChatUserInfoByOpenId(String openId);

    /**
     * 获取普通accessToken
     * @return
     */
    Result<?> getNormalAccessToken();

    /**
     * 公众号创建菜单
     * @param jsonObject
     * @return
     */
    Result<?> createMenu(JSONObject jsonObject);

    /**
     * 调用微信生成预支付交易单
     * @param jsonObject
     * @return
     */
    Result<?> createOrder(JSONObject jsonObject) throws Exception;

    /**
     * 根据商户订单号查询订单
     * @param outTradeNo
     * @return
     */
    Result<?> queryOrderByOutTradeNo(String outTradeNo) throws URISyntaxException, IOException, NotFoundException, GeneralSecurityException, HttpCodeException, Exception;

    /**
     * 根据微信支付订单号查询订单
     * @param transactionId
     * @return
     */
    Result<?> queryOrderByTransactionId(String transactionId) throws IOException, URISyntaxException, Exception;

    /**
     * 关闭订单
     * @param outTradeNo
     * @return
     */
    Result<?> closeOrder(String outTradeNo) throws IOException, Exception;

    /**
     * 订单支付结果通知
     * @param request
     * @param response
     * @return
     */
    Map<String,String> notify(HttpServletRequest request, HttpServletResponse response) throws IOException, GeneralSecurityException, HttpCodeException, NotFoundException, ValidationException, ParseException, Exception;

    /**
     * 公众号向微信用户推送模板消息
     * @param jsonObject
     * @return
     */
    Result<?> sendTemplateMsgToWxUser(JSONObject jsonObject) throws IOException;
}
